package com.xsherl.leetcode.solution;

/**
 * @Author: sherl
 * @Date: 2021/5/24 21:02
 */
public class Distinct1 {

    public int distinct1(char[] chars1, char[] chars2, int xi, int xj, int yi, int yj) {
        if (yi == yj) {
            return 1;
        } else if (xi == xj) {
            return 0;
        }
        int count = 0;
        int ym = (yi + yj) / 2;
        for (int xm = xi; xm < xj; ++xm) {
            if (chars1[xm] == chars2[ym]) {
                int a = distinct1(chars1, chars2, xi, xm, yi, ym);
                int b = distinct1(chars1, chars2, xm + 1, xj, ym + 1, yj);
                count += a * b;
            }
        }
        return count;
    }

}
